package cn.com.starbucks.activity.config;

import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Description: RabbitMQ客户端配置
 *
 * @author tecsmile@outlook.com
 * @version 1.0
 * @date 2021/4/19 6:40 下午
 **/
@Configuration
public class RabbitClientConfig {
    @Bean
    public RabbitTemplate rabbitTemplate(AbstractConnectionFactory connectionFactory) {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
        rabbitTemplate.setMandatory(true);
        return rabbitTemplate;
    }
}
